home *** CD-ROM | disk | FTP | other *** search
/ Amiga Plus 1999 #2 / Amiga Plus CD - 1999 - No. 2.iso / System-Boost / Grafik / MetaView / ARexx-Examples / DrawStudio_Import.dsrx < prev    next >
Text File  |  1998-11-08  |  2KB  |  105 lines

  1. /* Graphik Import in DrawStudio mittels MetaView */
  2.  
  3. METAVIEW = ':Aminet/MetaView/MetaView'    /* Please complete the path */
  4.  
  5. OPTIONS RESULTS
  6. SIGNAL ON FAILURE
  7. SIGNAL ON SYNTAX
  8.  
  9. /*
  10. ** Looking for our start process
  11. */
  12.  
  13. DSPORT = ADDRESS()
  14. if (LEFT(DSPORT, 10) ~= "DRAWSTUDIO") then do /* not started from DrawStudio */
  15.     say "Please start me from DrawStudio!"
  16.     EXIT
  17. end
  18. ADDRESS VALUE DSPORT
  19.     PROJECT_LOCK
  20.  
  21. /*
  22. ** Create a new Metaview process:
  23. ** first look for the allready running processes
  24. ** then the new Port will be the next one
  25. */
  26.  
  27. do NUMBER = 0 to 20
  28.     if (SHOW(PORTS,"METAVIEW." || NUMBER) = 0) then
  29.     leave
  30. end
  31.  
  32. /*
  33. ** Searching for MetaView: 1. our path above,
  34. **    2. path in env:MetaView.path
  35. ** or 3. you must have a assign "MetaView:"
  36. */
  37.  
  38. if (EXISTS(METAVIEW)=0) then do
  39.     if OPEN("MVVAR","env:MetaView.path","Read") then do
  40.         METAVIEW = READLN("MVVAR")
  41.     end
  42.     if (EXISTS(METAVIEW)=0) then do
  43.         METAVIEW = "MetaView:MetaView"
  44.     end
  45. end
  46.  
  47. /*
  48. ** Enable warnings for WaitForPort
  49. */
  50.  
  51. OPTIONS FAILAT 5
  52. ADDRESS COMMAND
  53.     "run " || METAVIEW || " NODISPLAY"
  54.     MVPORT = "METAVIEW." || NUMBER
  55.     "WaitForPort " || MVPORT
  56.  
  57. /*
  58. ** Ignore the other errors
  59. */
  60.  
  61. OPTIONS FAILAT 21
  62.  
  63. ADDRESS VALUE DSPORT
  64.     REQ_FILE '"Please choose a file to import..."' '"ram:"' STEM req.
  65.     if req.result == 0 then do
  66.         EXIT
  67.     end
  68.  
  69. /*
  70. ** Do all needed thinks with MetaView (LOAD,SAVE,QUIT...)
  71. */
  72.  
  73. ADDRESS VALUE MVPORT
  74.     LOAD '"'req.file'"'
  75.     SAVE "t:test.dr2d" AS DR2D
  76.     QUIT
  77.  
  78. /*
  79. **  Import the temporary file in application
  80. */
  81.  
  82. ADDRESS VALUE DSPORT
  83.     PROJECT_PLACE "t:test.dr2d"
  84.     REDRAW_OFF
  85.     OBJECT_SELECT
  86.     OBJECT_GROUP
  87.     REDRAW_ON
  88.     PROJECT_UNLOCK
  89.     EXIT
  90.  
  91. FAILURE:
  92.     ADDRESS COMMAND
  93.     REQUESTCHOICE "Error" """Can't find" METAVIEW "!""" "OK"
  94.     ADDRESS VALUE DSPORT
  95.     REDRAW_ON
  96.     PROJECT_UNLOCK
  97.     EXIT
  98.  
  99. SYNTAX:
  100.     say "Error on line" SIGL ":" ERRORTEXT(RC) "!"
  101.     ADDRESS VALUE DSPORT
  102.     REDRAW_ON
  103.     PROJECT_UNLOCK
  104.     EXIT
  105.